package com.baizhi.service;

import com.baizhi.dao.ProductSizeMapper;
import com.baizhi.entity.ProductSize;
import com.baizhi.entity.ProductSizeExample;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.UUID;

@Service("productSize")
@Transactional
public class ProductSizeServiceImpl implements ProductSizeService {

    @Resource
    private ProductSizeMapper productSizeMapper;
    ProductSizeExample productSizeExample = new ProductSizeExample();
    @Override
    public List<ProductSize> findAll() {
        return productSizeMapper.selectByExample(productSizeExample);
    }

    @Override
    public ProductSize findById(String id) {
        return productSizeMapper.selectByPrimaryKey(id);
    }

    @Override
    public void save(ProductSize productSize) {
        productSize.setId(UUID.randomUUID().toString());
        productSizeMapper.insert(productSize);
    }

    @Override
    public void update(ProductSize productSize) {
        productSizeMapper.updateByPrimaryKeySelective(productSize);
    }

    @Override
    public void delete(String id) {
        productSizeMapper.deleteByPrimaryKey(id);
    }
}
